/**
 * 
 */
package com.manthano.util.search;

import java.util.LinkedHashMap;
import java.util.Map;

/**
 * @author DELL
 * @param <k>
 */
public class FacetedSearchResult<k> extends SearchResult<k>
{

	/**
	 * 
	 */
	private static final long							serialVersionUID	= -7722125970814093679L;

	private Map<String, LinkedHashMap<String, Long>>	facetResult			= new LinkedHashMap<String, LinkedHashMap<String, Long>>();
	private Map<String, LinkedHashMap<String, Double>>	statResult			= new LinkedHashMap<String, LinkedHashMap<String, Double>>();

	/**
	 * @return the facetResult
	 */
	public Map<String, LinkedHashMap<String, Long>> getFacetResult()
	{
		return facetResult;
	}

	/**
	 * @param facetResult
	 *            the facetResult to set
	 */
	public void setFacetResult(Map<String, LinkedHashMap<String, Long>> facetResult)
	{
		this.facetResult = facetResult;
	}

	/**
	 * @return the statResult
	 */
	public Map<String, LinkedHashMap<String, Double>> getStatResult()
	{
		return statResult;
	}

	/**
	 * @param statResult
	 *            the statResult to set
	 */
	public void setStatResult(Map<String, LinkedHashMap<String, Double>> statResult)
	{
		this.statResult = statResult;
	}

	/**
	 * @param facetField
	 * @param value
	 * @param count
	 */
	public void addFacetResult(String facetField, String value, long count)
	{
		LinkedHashMap<String, Long> facetCountMap = getFacetResult().get(facetField);
		if (facetCountMap == null)
		{
			facetCountMap = new LinkedHashMap<String, Long>();
			facetCountMap.put(value, count);
			getFacetResult().put(facetField, facetCountMap);
		}
		else
		{
			facetCountMap.put(value, count);
		}
	}

	/**
	 * @param facetField
	 * @param value
	 * @param statValue
	 */
	public void addStatResult(String facetField, String value, double statValue)
	{
		LinkedHashMap<String, Double> statMap = getStatResult().get(facetField);
		if (statMap == null)
		{
			statMap = new LinkedHashMap<String, Double>();
			statMap.put(value, statValue);
			getStatResult().put(facetField, statMap);
		}
		else
		{
			statMap.put(value, statValue);
		}
	}
}
